home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Sources / ValueStream.cpp < prev   
Encoding:
Text File  |  1994-04-21  |  4.7 KB  |  165 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            ValueStream.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef _VALUESTREAM_
  14. #include "ValueStream.h"
  15. #endif
  16.  
  17. // ----- Framework Includes -----
  18.  
  19. #ifndef FWSTDDEF_H
  20. #include <FWStdDef.h>
  21. #endif
  22.  
  23. // ----- OpenDoc Inlcudes -----
  24.  
  25. #ifndef _STORAGEU_
  26. #include "StorageU.h"
  27. #endif
  28.  
  29. #pragma segment TextPartSegment
  30.  
  31. //========================================================================================
  32. // CLASS CValueStream
  33. //========================================================================================
  34.  
  35. //----------------------------------------------------------------------------------------
  36. // CValueStream::CValueStream
  37. //----------------------------------------------------------------------------------------
  38.  
  39. CValueStream::CValueStream() :
  40.     fSU(NULL)
  41. {
  42. }
  43.     
  44. //----------------------------------------------------------------------------------------
  45. // CValueStream::InitValueStream
  46. //----------------------------------------------------------------------------------------
  47.  
  48. void CValueStream::InitValueStream(XMPStorageUnit *su)
  49. {
  50.     CStream::IStream();
  51.     fSU = su;
  52. }
  53.  
  54. //----------------------------------------------------------------------------------------
  55. // CValueStream::~CValueStream
  56. //----------------------------------------------------------------------------------------
  57.  
  58. CValueStream::~CValueStream()
  59. {
  60. }
  61.  
  62. //----------------------------------------------------------------------------------------
  63. // CValueStream::WriteBytes
  64. //----------------------------------------------------------------------------------------
  65.  
  66. OSErr CValueStream::WriteBytes(const void* theBytes, long bytesCount)
  67. {
  68.     fSU->SetValue(bytesCount, (void *) theBytes);    
  69.     return noErr;
  70. }
  71.  
  72. //----------------------------------------------------------------------------------------
  73. // CValueStream::ReadBytes
  74. //----------------------------------------------------------------------------------------
  75.  
  76. OSErr CValueStream::ReadBytes(void* theBytes, long bytesCount)
  77. {
  78.     fSU->GetValue(bytesCount, theBytes);
  79.     return noErr;
  80. }
  81.  
  82.  
  83. //----------------------------------------------------------------------------------------
  84. // CValueStream::GetPosition
  85. //----------------------------------------------------------------------------------------
  86.  
  87. long CValueStream::GetPosition() const
  88. {
  89.     return fSU->GetOffset();
  90. }
  91.  
  92. //----------------------------------------------------------------------------------------
  93. // CValueStream::SetPosition
  94. //----------------------------------------------------------------------------------------
  95.  
  96. void CValueStream::SetPosition(long newPosition)
  97. {
  98.     fSU->SetOffset(newPosition);
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. // CValueStream::Skip
  103. //----------------------------------------------------------------------------------------
  104.  
  105. void CValueStream::Skip(long count)
  106. {
  107.     fSU->SetOffset(fSU->GetOffset() + count);
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. // CValueStream::GetSize
  112. //----------------------------------------------------------------------------------------
  113.  
  114. long CValueStream::GetSize() const
  115. {
  116.     return fSU->GetSize();
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. // CValueStream::Append
  121. //----------------------------------------------------------------------------------------
  122.  
  123. OSErr CValueStream::Append(long count)
  124. {
  125. FW_UNUSED(count);
  126.  
  127.     DebugStr("\pCValueStream::Append(long count)");
  128.     
  129.     return noErr;
  130. }
  131.     
  132. //----------------------------------------------------------------------------------------
  133. // CValueStream::Empty
  134. //----------------------------------------------------------------------------------------
  135.  
  136. void CValueStream::Empty()
  137. {
  138.     fSU->DeleteValue(0);
  139. }
  140.  
  141. //----------------------------------------------------------------------------------------
  142. // CValueStream::Load
  143. //----------------------------------------------------------------------------------------
  144.  
  145. OSErr CValueStream::Load(long size, Ptr* data)
  146. {
  147. FW_UNUSED(size);
  148. FW_UNUSED(data);
  149.  
  150.     DebugStr("\pCValueStream::Load(long size, Ptr* data)");
  151.     
  152.     return noErr;
  153. }
  154.     
  155. //----------------------------------------------------------------------------------------
  156. // CValueStream::Unload
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void CValueStream::Unload(Ptr data)
  160. {
  161. FW_UNUSED(data);
  162.  
  163.     DebugStr("\pCValueStream::Unload(Ptr data)");
  164. }
  165.